<template>
	<view class="shelf">
		<block v-for="book in list">
			<book-card :name="book.name" :author="book.author" :img="book.img" :sourceSite="book.sourceSite"
				:tags="[book.state,book.classify,book.id]" :synopsis="book.synopsis" type="list" :isLink="true"
				:link="'/pages/contents/contents?id='+book.id" class="card">
			</book-card>
		</block>
	</view>
</template>

<script>
	import utils from '@/static/js/utils.js'

	export default {
		data() {
			return {
				list: null
			}
		},
		onPullDownRefresh() {
			this.shelfLoad()
		},
		methods: {
			shelfLoad() {
				let that = this;
				utils.http.get(
					"/shelf/profileShelf"
				).then(res => {
					if (res.status == 200) {
						this.list = res.data
					}
				}).finally(() => {
					uni.stopPullDownRefresh()
				})
			},
		},
		onLoad() {
			this.shelfLoad()
			uni.setNavigationBarTitle({
				title: "书架"
			})
		}
	}
</script>

<style scoped>
	.shelf {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.card {
		margin: 5px 10px;
		padding: 10px 10px;
		width: 85%;
	}
</style>
